from django.urls import path
from rest_framework.routers import DefaultRouter
from .views import *

urlpatterns = [
    # 要通过as_view变成一个可调用的方法
    path('payment/<pk>/', PaymentViewSet.as_view({'get': 'retrieve'}))
]
router = DefaultRouter()
router.register('classification', ClassificationViewSet)
router.register('classifications', ClassificationStudentViewSet)
router.register('commodity', CommodityViewSet)
router.register('commoditys', CommodityStudentViewSet)
router.register('cart', ShoppingCartViewSet, basename='shopping_cart')  # 当试图有属性是自定义的时候,需要basename指定一下数据库表
router.register('order', OrderViewSet, basename='order')
urlpatterns += router.urls

